home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 December / DPPCPRO1205.ISO / Essentials / Programming / Basic4GL / Setup Basic4GL v2.3.1.exe / $INSTDIR / Programs / nehe5.gb < prev    next >
Encoding:
Text File  |  2005-07-29  |  4.1 KB  |  89 lines

  1.     dim rtri#                                        ' Angle for the triangle
  2.     dim rquad#                                        ' Angle for the quad    
  3.  
  4.     glEnable (GL_CULL_FACE)
  5.  
  6.     while true
  7.         glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)    ' Clear screen and depth buffer
  8.         glLoadIdentity()                               ' Reset the current modelview matrix
  9.     
  10.         glTranslatef(-1.5,0.0,-6.0)                 ' Move left 1.5 units and into the screen 6.0
  11.         glRotatef(rtri#,0.0,1.0,0.0)            ' Rotate the triangle on the Y axis ( NEW )
  12.  
  13.         glBegin(GL_TRIANGLES)                        ' Drawing using triangles
  14.                  glColor3f(1.0,0.0,0.0)              ' Red
  15.             glVertex3f( 0.0, 1.0, 0.0)            ' Top of triangle (front)
  16.             glColor3f(0.0,1.0,0.0)            ' Green
  17.             glVertex3f(-1.0,-1.0, 1.0)            ' Left of triangle (front)
  18.             glColor3f(0.0,0.0,1.0)            ' Blue
  19.             glVertex3f( 1.0,-1.0, 1.0)            ' Right of triangle (front)
  20.  
  21.                  glColor3f(1.0,0.0,0.0)            ' Red
  22.             glVertex3f( 0.0, 1.0, 0.0)            ' Top of triangle (right)
  23.             glColor3f(0.0,0.0,1.0)            ' Blue
  24.             glVertex3f( 1.0,-1.0, 1.0)            ' Left of triangle (right)
  25.             glColor3f(0.0,1.0,0.0)            ' Green
  26.             glVertex3f( 1.0,-1.0, -1.0)        ' Right of triangle (right)
  27.  
  28.             glColor3f(1.0,0.0,0.0)            ' Red
  29.             glVertex3f( 0.0, 1.0, 0.0)            ' Top of triangle (back)
  30.             glColor3f(0.0,1.0,0.0)            ' Green
  31.             glVertex3f( 1.0,-1.0, -1.0)        ' Left of triangle (back)
  32.             glColor3f(0.0,0.0,1.0)            ' Blue
  33.             glVertex3f(-1.0,-1.0, -1.0)        ' Right of triangle (back)
  34.  
  35.             glColor3f(1.0,0.0,0.0)            ' Red
  36.             glVertex3f( 0.0, 1.0, 0.0)            ' Top of triangle (left)
  37.             glColor3f(0.0,0.0,1.0)            ' Blue
  38.             glVertex3f(-1.0,-1.0,-1.0)            ' Left of triangle (left)
  39.             glColor3f(0.0,1.0,0.0)            ' Green
  40.             glVertex3f(-1.0,-1.0, 1.0)            ' Right of triangle (left)
  41.         glEnd()                            ' Finished Drawing The Triangle
  42.  
  43.         glLoadIdentity()                    ' Reset the current modelview matrix
  44.         glTranslatef(1.5,0.0,-6.0)                ' Move right 1.5 units and into the screen 6.0
  45.         glRotatef(rquad#,1.0,0.0,0.0)            ' Rotate the quad on the X axis ( NEW )
  46.         glColor3f(0.5,0.5,1.0)                ' Set the color to blue one time only
  47.  
  48.         glBegin(GL_QUADS)                        ' Draw a quad
  49.             glColor3f(0.0,1.0,0.0)            ' Set the color to green
  50.             glVertex3f( 1.0, 1.0,-1.0)            ' Top right of the quad (top)
  51.             glVertex3f(-1.0, 1.0,-1.0)            ' Top left of the quad (top)
  52.             glVertex3f(-1.0, 1.0, 1.0)            ' Bottom left of the quad (top)
  53.             glVertex3f( 1.0, 1.0, 1.0)            ' Bottom right of the quad (top)
  54.             glColor3f(1.0,0.5,0.0)            ' Set the color to orange
  55.             glVertex3f( 1.0,-1.0, 1.0)            ' Top right of the quad (bottom)
  56.             glVertex3f(-1.0,-1.0, 1.0)            ' Top left of the quad (bottom)
  57.             glVertex3f(-1.0,-1.0,-1.0)            ' Bottom left of the quad (bottom)
  58.             glVertex3f( 1.0,-1.0,-1.0)            ' Bottom right of the quad (bottom)
  59.  
  60.             glColor3f(1.0,0.0,0.0)            ' Set the color to red
  61.             glVertex3f( 1.0, 1.0, 1.0)            ' Top right of the quad (front)
  62.             glVertex3f(-1.0, 1.0, 1.0)            ' Top left of the quad (front)
  63.             glVertex3f(-1.0,-1.0, 1.0)            ' Bottom left of the quad (front)
  64.             glVertex3f( 1.0,-1.0, 1.0)            ' Bottom right of the quad (front)
  65.  
  66.             glColor3f(1.0,1.0,0.0)            ' Set the color to yellow
  67.             glVertex3f( 1.0,-1.0,-1.0)            ' Bottom left of the quad (back)
  68.             glVertex3f(-1.0,-1.0,-1.0)            ' Bottom right of the quad (back)
  69.             glVertex3f(-1.0, 1.0,-1.0)            ' Top right of the quad (back)
  70.             glVertex3f( 1.0, 1.0,-1.0)            ' Top left of the quad (back)
  71.  
  72.             glColor3f(0.0,0.0,1.0)              ' Set the color to blue
  73.             glVertex3f(-1.0, 1.0, 1.0)            ' Top right of the quad (left)
  74.             glVertex3f(-1.0, 1.0,-1.0)            ' Top left of the quad (left)
  75.             glVertex3f(-1.0,-1.0,-1.0)            ' Bottom left of the quad (left)
  76.             glVertex3f(-1.0,-1.0, 1.0)            ' Bottom right of the quad (left)
  77.  
  78.             glColor3f(1.0,0.0,1.0)            ' Set the color to violet
  79.             glVertex3f( 1.0, 1.0,-1.0)            ' Top right of the quad (right)
  80.             glVertex3f( 1.0, 1.0, 1.0)            ' Top left of the quad (right)
  81.             glVertex3f( 1.0,-1.0, 1.0)            ' Bottom left of the quad (right)
  82.             glVertex3f( 1.0,-1.0,-1.0)            ' Bottom right of the quad (right)
  83.         glEnd()
  84.  
  85.         rtri# = rtri# + 0.2                        ' Increase the rotation variable for the triangle 
  86.         rquad# = rquad# - 0.15                 ' Decrease the rotation variable for the quad     
  87.         SwapBuffers ()
  88.     wend
  89.